﻿@{
    ViewBag.Title = "Document";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


@using Common.BaseLibrary.Authorization
@using DepartmentWork.Model
@model DepartmentWork.Model.ProjectMaintenanceDocumentViewModel

<link href="~/Assets/plugins/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" />
<script src="~/Assets/plugins/bootstrap-select/bootstrap-select.min.js"></script>
<link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />
<link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css" rel="stylesheet" />
<script src="~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="~/Assets/plugins/chosen/chosen.jquery.min.js"></script>
<script src="~/Assets/js/pages/form-elements.js"></script>
<style>
    .btn-default {
        color: #333;
        background-color: #FFF;
        border-color: #CCC;
        height: 34px;
    }
</style>



<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="@Url.Action("Index","Home",new{area=""})"><i class="icon fa fa-home"></i>主页</a></li>
            <li><a href="~/PerationAndMaintenanceArea/Maintenance/Maintenance"><i class="fa fa-envelope"></i>运维项目管理</a></li>
            <li><a href="@Url.Action("Particulars","Maintenance",new{area="PerationAndMaintenanceArea",projectId=ViewBag.ID})"><i class="fa fa-envelope"></i>运维工作详情</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>文档</a></li>
        </ol>
    </div>
</div>




@{
    if (ViewBag.Flag == "True")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;@ViewBag.FlagInfo！</strong>
    </div>
    }
    if (ViewBag.Flag == "False")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;操作失败！</strong> @ViewBag.FlagInfo
    </div>
    }
}
 



<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading bk-bg-primary">
                <h6><i class="fa fa-table red"></i><span style="font-size: medium" class="break">@ViewBag.RecordName 运维项目的文档</span></h6>
                  @if (ViewBag.IsAdmin == true || ViewBag.FZ == true)
                  {
                    <div class="panel-actions">
                    <a data-toggle="modal" data-target="#TaskBookCreateModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;新增文档&nbsp;&nbsp;</a>
                    </div>
                  }
                
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                            <tr>
                                <th style="text-align: center">创建人</th>
                                <th style="text-align: center">创建时间</th>
                        @*        <th style="text-align: center">文档描述</th>*@
                                <th style="text-align: center">文档附件</th>
                                <th style="text-align: center">文档相关操作</th>
                            </tr>
                        </thead>
                        <tbody id="cwl">
                            @if (ViewBag.Record != null)
                            {
                                foreach (ProjectMaintenanceDocumentViewModel item in ViewBag.Record)
                                {
                                <tr>
                                    <td style="text-align: center;color:black">@item.document_founder</td>
                                    <td style="text-align: center;color:black">@item.document_datetime.ToString("yyyy-MM-dd")</td>
                                @*  <td style="text-align: center;color:black">@item.document_describe</td>*@


                                    <td style="text-align: center">
                                        <a data-target="#BugInfoModal" onclick="ShowTaskBookInfoModal('@item.document_id')" data-toggle="modal" style="color:green" >@item.document_accessory</a>
                                    </td>

                                    <td style="text-align: center;color:black">
                                        <a onclick="xiangqing('@item.document_id')" data-toggle="modal" data-target="#XiangQing" style="color:blue">&nbsp;&nbsp;描述&nbsp;&nbsp;</a>
                                          @if (ViewBag.IsAdmin == true || ViewBag.FZ == true)
                                          {
                                           <a onclick="getid('@item.document_id')" data-toggle="modal" data-target="#Compile" style="color:blue">&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>
                                           <a onclick="deleteid('@item.document_id')" data-toggle="modal" data-target="#Delete" style="color:red">&nbsp;&nbsp;删除&nbsp;&nbsp;</a>
                                          }
                                       
                                    </td>
                                </tr>
                                }
                            }
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    function getid(bugId) {
        $.ajax({
            type: "POST",
            //url: "/KSManager/PerationAndMaintenanceArea/Maintenance/documentUpdat",
            url:'@Url.Action("documentUpdat","Maintenance",new{area="PerationAndMaintenanceArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {

                document.getElementById("t_document_name").value = (data["document_founder"]);
                document.getElementById("t_document_content").value = (data["document_describe"]);
                document.getElementById("compile_document_id").value = (data["document_id"]);
                document.getElementById("t_document_accessory").value = (data["document_accessory"]);
                

            }
        });

    }

</script>

<script>
    function deleteid(bugId) {

        $.ajax({
            type: "POST",
            //url: "/KSManager/PerationAndMaintenanceArea/Maintenance/documentDelete",
            url:'@Url.Action("documentDelete","Maintenance",new{area="PerationAndMaintenanceArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                $("#delete_document_id").val(data["document_id"]);
            }
        });
    }

</script>





<!-- 下载附件 模态框（Modal） -->
<script>
    function ShowTaskBookInfoModal(bugId) {
        $.ajax({
            type: "POST",
            //url: "/KSManager/PerationAndMaintenanceArea/Maintenance/GetReacord",
            url:'@Url.Action("GetReacord","Maintenance",new{area="PerationAndMaintenanceArea"})',
            data: "bugId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {

                if (data["BugFileSaveName"] == "") {

                    $("#a_DownloadBugFile").text("");
                }
                else {

                    $("#a_DownloadBugFile").text(data["BugFileShowName"]);
                    $("#a_DownloadBugFile").attr("href", '@Url.Content("~/Home/DownLoadFile?filePath=")' + data["BugFileSaveName"] + "&type=Document&fileName=" + data["BugFileSaveName"]);

                }

            }
        });
    }

</script>

@*文档校验*@
 <script>
     $(document).ready(function () {
         $("#document_id").validate({
             rules: {
                 tb_document_founder: { required: true, maxlength: 6 },
                 tb_document_describe: { required: true },
             },
             messages: {
                 tb_document_founder: { required: "创建人姓名不能为空", maxlength: "名字长度不能超过6个字" },
                 tb_document_describe: { required: "描述不能为空" },
             },
             errorPlacement: function (error, element) {
                 error.appendTo(element.next("span.t_document_founder"));
                 error.appendTo(element.next("span.t_document_describe"));
             }
         });
         $("span.t_document_founder").css("color", "red");
         $("span.t_document_describe").css("color", "red");
     })
    </script>




<div class="modal fade" id="TaskBookCreateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">新增文档</h4>
            </div>
            <form id="document_id" enctype="multipart/form-data" action="@Url.Action("inser_Document", "Maintenance", new { area = "PerationAndMaintenanceArea" })" method="POST" >

                <div class="modal-body">
                    <input type="hidden" name="hid_ProjectId" />
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">创建人姓名：</label>
                        <div class="col-md-9">
                            <input name="tb_document_founder" style="border-color: cornflowerblue" class="form-control" placeholder="Text" type="text">
                            <span class="t_document_founder"></span>
                            <input type="hidden" name="hid_document_id" value="@ViewBag.ID"/>
                        </div>
                    </div>
                    <br />


                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">文档描述：</label>
                        <div class="col-md-9">
                            <textarea name="tb_document_describe" class="form-control" rows="3"></textarea>
                            <span class="t_document_describe"></span>
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">附件：</label>
                        <div class="col-md-9">
                            <input name="tb_document_accessory" id="" style="border-color: cornflowerblue" placeholder="Text" type="file">
                        </div>
                    </div>


                    <br />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="新增" class="btn btn-primary" />
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>

<!-- 编辑文档 模态框（Modal） -->
<div class="modal fade" id="Compile" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">编辑文档</h4>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("updat_Document", "Maintenance", new { area = "PerationAndMaintenanceArea" })" method="POST" >

                <div class="modal-body">
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">创建人姓名：</label>
                        <div class="col-md-9">
                            <input name="tb_document_name" id="t_document_name" style="border-color: cornflowerblue" class="form-control" placeholder="Text" type="text">
                            <input type="hidden" id="compile_document_id" name="td_document_id" value="" />
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">文档描述：</label>
                        <div class="col-md-9">
                            <textarea name="tb_document_content" id="t_document_content" class="form-control" rows="3"></textarea>
                        </div>
                    </div>
                    <br />

                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">附件：</label>
                        <div class="col-md-9">
                            <input name="tb_document_accessory" id="t_document_accessory" style="border-color: cornflowerblue" placeholder="Text" type="file">
                        </div>
                    </div>
                    <br />

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="修改" class="btn btn-primary" />
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>

<!-- 删除记录 模态框（Modal） -->
<div class="modal fade" id="Delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("delete_Document", "Maintenance", new { area = "PerationAndMaintenanceArea" })" method="POST" >

                <div class="modal-body">
                    <div class="row">
                        <label class="col-md-3 control-label" for="text-input">确定删除此项记录么</label>
                        <input type="hidden" id="delete_document_id" name="delete_document_idd" value="" />
                    </div>
                    <br />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="确定" class="btn btn-primary" />
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>


<!-- 下载附件 模态框（Modal） -->
<div class="modal fade" id="BugInfoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">文档附件</h4>
            </div>
            <div class="modal-body" style="font-size: small">

                <div class="row">
                    <label class="col-md-3 control-label" for="text-input">点击下载：</label>
                    <div class="col-md-9">
                        <a id="a_DownloadBugFile">
                       @*     <label id="lb_BugFile" style="width: 100%" class="col-md-8 control-label" for="text-input"></label>*@
                        </a>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    关闭
                </button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>












<script>
    function xiangqing(bugId) {
        $.ajax({
            type: "POST",
            //url: "/KSManager/PerationAndMaintenanceArea/Maintenance/documentUpdat",
            url:'@Url.Action("documentUpdat","Maintenance",new{area="PerationAndMaintenanceArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                document.getElementById("xq_document_content").value = (data["document_describe"]);
            }
        });

    }

</script>
<!-- 文档描述窗口 模态框（Modal） -->
<div class="modal fade" id="XiangQing" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel1">文档描述</h4>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("updat_Document", "Maintenance", new { area = "PerationAndMaintenanceArea" })" method="POST" >

                <div class="modal-body">
                    <div class="row">
                        <div>
                            <textarea readonly="readonly" name="xq_document_content" id="xq_document_content" class="form-control" rows="5"></textarea>
                        </div>
                    </div>
                    <br />
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>

